/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.entity;

import java.util.Set;

import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.GenericGenerator;
import org.jackysoft.util.MySqlSchema;

/**
 * This class exists to seperate the persistence of the Steps. By seperating out
 * the Current Step from the Previous Step classes, they can be easily written
 * into seperate tables.
 * 
 * @see {@link HibernateHistoryStep}
 */
@Entity
@Table(name = "os_currentstep",schema=MySqlSchema.Businessbase)
public class HibernateCurrentStep extends HibernateStep {
	

	/**
	 * 
	 */
	private static final long serialVersionUID = -2190412918990223608L;

	// ~ Constructors
	// ///////////////////////////////////////////////////////////
	public HibernateCurrentStep() {

	}

	public HibernateCurrentStep(HibernateStep step) {
		super(step);
	}

	@ElementCollection(fetch=FetchType.EAGER)
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.DELETE})
	@CollectionTable(name = "os_currentstep_prev",schema=MySqlSchema.Businessbase, joinColumns = @JoinColumn(name = "id"))
	@Column(name = "previous_id")
	public Set<Long> getPreviousSteps() {
		return super.previousSteps;
	}

	@Id
	@GeneratedValue(generator = "nvt")
	@GenericGenerator(name = "nvt", strategy = "native")
	public long getId() {
		return id;
	}
}
